package com.easy.project.config;

import cn.dev33.satoken.stp.StpInterface;
import com.easy.project.service.system.ISysAuthService;
import com.easy.project.util.SaTokenUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * sa-token 权限配置
 */
@Component
public class StpInterfaceImpl implements StpInterface {

    @Resource
    private ISysAuthService sysAuthService;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        // 根据loginId获取角色所有的接口路径
        Long loginIdLong = Long.valueOf((String) loginId);
        return sysAuthService.getPermissionListByUserId(loginIdLong);
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        // 根据loginId获取角色所有的接口路径
        Long loginIdLong = Long.valueOf((String) loginId);
        return sysAuthService.getRoleCodeListByUserId(loginIdLong);
    }
}
